#!/usr/bin/env python
#-*- coding:utf-8 -*-

'''
Created on 2012-01-15

@author: zhangchong
'''


#/data/log/log/[0-9,a-z]*/[0-9]*[0-9]

import sys
import os
import json
import string
import MySQLdb
import simplejson
import Config
import datetime

import CpLog
import Split
import Statist


try:
    import accuTotal
    import accuUserPerDay
    import newUserPerDay
except:
    pass

def main(date=""):
    if(date == ""):
        yesterday = datetime.date.today() - datetime.timedelta(days=1)
        format = "%Y%m%d"
        yesterday = yesterday.strftime("%Y%m%d")
        yesterday = str(yesterday)
   
        argv = sys.argv
        try:
            date = argv[1]
        except:
            date = yesterday
    
    #建立log目录
    if(not os.path.exists(Config.ScriptsDir + "log")):
       os.makedirs(Config.ScriptsDir + "log")
    else:
       if(not os.path.isdir(Config.ScriptsDir + "log")):     
            os.makedirs(Config.ScriptsDir + "log")
               
    CpLog.cpLog(date)
    Split.split(date)
    Statist.stat(date, isSaveDB=True)   
    
       
if __name__ == "__main__":
    main()
    
    
    
    
 
    
    
   


    
    
   
